package me.ezitku.base.extensions

import java.text.DecimalFormat
import java.text.NumberFormat

fun Double.format(decimal: Int): Double {
    var d = ""
    for (i in 1..decimal) {
        d += "#"
    }
    val nf = DecimalFormat("##.$d") as NumberFormat
    return nf.format(this).toDouble()
}

fun Float.number_format(decimal: Int): Double {
    return toDouble().format(decimal)
}

fun Double.format_price(): Double {
    return format(2)
}
